package com.newcapec.lesson3;

import java.util.Objects;

public class Person extends Object{

    private int age;
    private String name;
    private String sex;
    private String birthday;

    public Person(){}

    public Person(int age, String name){
        this.age = age;
        this.name = name;
    }

    public Person(int age, String name, String sex, String birthday){
       /* this.age = age;
        this.name = name;*/

        this(age,name);
        this.sex = sex;
        this.birthday = birthday;
    }



    public Person(Person person){
        this.age = person.age;
        this.name = person.name;
        this.sex = person.sex;
        this.birthday = person.birthday;
    }

    void fun(int age){
        String name = "张三";

    }

    //如果equals返回为真，则hashCode一定要一致  规则
    @Override
    public boolean equals(Object o) {
      if(this == o){
          return true;
      }

      if(o instanceof Person){
          Person person = (Person) o;
          if(person.name.equals(this.name) && person.age == this.age &&
                  person.sex.equals(this.sex) && person.birthday.equals(this.birthday)){
            return true;
          }
      }


      return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(age, name, sex, birthday);
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", birthday='" + birthday + '\'' +
                '}';
    }
}
